import request from '@/utils/request'
import type { IUserData, IUserList, IConfig, IUserLoginResult } from './types/user'

// 获取User列表表格数据
export const reqUserData = (data: IConfig) => {
  return request<IUserData>({
    url: '/user/getUserData',
    method: 'get',
    data
  })
}

// 删除用户
export const reqDeleteUser = (data: { id: string }) => {
  return request({
    url: '/user/deleteUser',
    method: 'get',
    data
  })
}

// 新增用户
export const reqAddUser = (data: IUserList) => {
  return request({
    url: '/user/addUser',
    method: 'post',
    data
  })
}

// 更新用户
export const reqUpdateUser = (data: IUserList) => {
  return request({
    url: '/user/updateUser',
    method: 'post',
    data
  })
}
// 登录&获取菜单
export const reqLogin = (data: { username: string; password: string }) => {
  return request<IUserLoginResult>({
    url: '/user/login',
    method: 'post',
    data
  })
}
